package com.school.campus.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.school.common.annotation.Log;
import com.school.common.core.controller.BaseController;
import com.school.common.core.domain.AjaxResult;
import com.school.common.enums.BusinessType;
import com.school.campus.domain.ClubActivityType;
import com.school.campus.service.IClubActivityTypeService;
import com.school.common.utils.poi.ExcelUtil;
import com.school.common.core.page.TableDataInfo;

/**
 * 社团活动类型Controller
 *
 * @author wwj
 * @date 2025-11-06
 */
@RestController
@RequestMapping("/campus/activityType")
public class ClubActivityTypeController extends BaseController {
    @Autowired
    private IClubActivityTypeService clubActivityTypeService;

    /**
     * 查询社团活动类型列表
     */
    @PreAuthorize("@ss.hasPermi('campus:activityType:list')")
    @GetMapping("/list")
    public TableDataInfo list(ClubActivityType clubActivityType) {
        startPage();
        List<ClubActivityType> list = clubActivityTypeService.selectClubActivityTypeList(clubActivityType);
        return getDataTable(list);
    }

    /**
     * 导出社团活动类型列表
     */
    @PreAuthorize("@ss.hasPermi('campus:activityType:export')")
    @Log(title = "社团活动类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ClubActivityType clubActivityType) {
        List<ClubActivityType> list = clubActivityTypeService.selectClubActivityTypeList(clubActivityType);
        ExcelUtil<ClubActivityType> util = new ExcelUtil<ClubActivityType>(ClubActivityType.class);
        util.exportExcel(response, list, "社团活动类型数据");
    }

    /**
     * 获取社团活动类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('campus:activityType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(clubActivityTypeService.selectClubActivityTypeById(id));
    }

    /**
     * 新增社团活动类型
     */
    @PreAuthorize("@ss.hasPermi('campus:activityType:add')")
    @Log(title = "社团活动类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClubActivityType clubActivityType) {
        return toAjax(clubActivityTypeService.insertClubActivityType(clubActivityType));
    }

    /**
     * 修改社团活动类型
     */
    @PreAuthorize("@ss.hasPermi('campus:activityType:edit')")
    @Log(title = "社团活动类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClubActivityType clubActivityType) {
        return toAjax(clubActivityTypeService.updateClubActivityType(clubActivityType));
    }

    /**
     * 删除社团活动类型
     */
    @PreAuthorize("@ss.hasPermi('campus:activityType:remove')")
    @Log(title = "社团活动类型", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(clubActivityTypeService.deleteClubActivityTypeByIds(ids));
    }
}
